
<template>
  <div id="orderData">
    <div class="top">
      <div class="one">
        <p v-if="info.type == 'store'">
          本门店今日已核销&nbsp;&nbsp;&nbsp;&nbsp;{{sNum}}
        </p>
        <p v-if="info.type == 'brand'">
          本品牌今日已核销&nbsp;&nbsp;&nbsp;&nbsp;{{bNum}}
        </p>
      </div>
      <div class="two">
        <a v-if="info.type == 'store'" href="#/orderDataList?type=0">查看本门店核销数据</a>
        <a v-if="info.type == 'brand'" href="#/orderDataList?type=1">查看本品牌核销数据</a>
      </div>
    </div>
    <tabbar>
      <tabbar-item link="/code">
        <img slot="icon" src="../../../wechat/static/images/tab_hx_n.png">
        <span slot="label" style="font-family: PingFang-SC-Medium;
    font-size: 0.24rem;
    color: #999999;">核销</span>
      </tabbar-item>
      <tabbar-item selected>
        <img slot="icon" src="../../../wechat/static/images/tab_ddsj_s.png">
        <span slot="label" style="font-family: PingFang-SC-Medium;
    font-size: 0.24rem;
    color: #ec1b24;">订单数据</span>
      </tabbar-item>
      <tabbar-item link="/centerB">
        <img slot="icon" src="../../../wechat/static/images/tab_grzx_n.png">
        <span slot="label" style="font-family: PingFang-SC-Medium;
    font-size: 0.24rem;
    color: #999999;">个人中心</span>
      </tabbar-item>
    </tabbar>
  </div>
</template>

<script>
import { Tabbar, TabbarItem } from "vux";
var date1 = new Date();
var dates = Date.parse(date1);
console.log(dates);
var datee = dates + 86400;
var date2 = new Date(datee)
var ys = date1.getFullYear()
var ms = date1.getMonth() + 1
var ds = date1.getDate()
var ye = date2.getFullYear()
var me = date2.getMonth() + 1
var de = date2.getDate()+1
var start = ys +
  "-" +
  (ms < 10 ? "0" + ms : ms) +
  "-" +
  (ds < 10 ? "0" + ds : ds)
var end = ye +
  "-" +
  (me < 10 ? "0" + me : me) +
  "-" +
  (de < 10 ? "0" + de : de)
console.log(start);
console.log(end);
export default {
  name: "orderData",
  data() {
    return {
      sNum: "",
      bNum: "",
      info:{}
    };
  },
  mounted() {
    this.getDetail()
    this.getListNumber();
  },
  created() {},
  methods: {
    getDetail() {
      let url =
        this.$CONSTANT.STORE.findEsStoreById +
        "?sessionId=" +
        this.$common.getCookie("sessionId");
      let param = {};
      // this.$vux.loading.show({
      //   text: "Loading"
      // });
      this.$common.post(url, param, res => {
        setTimeout(() => {
          this.$vux.loading.hide();
        }, 800);
        if (res.status == 200) {
          var bussData = res.data.bussData;
          this.info = bussData
        } else {
          this.$vux.toast.show({
            text: res.msg,
            type: "warn",
            width: "auto"
          });
        }
      });
    },
    getListNumber() {
      let url =
        this.$CONSTANT.COUPON.findStoreEsVirtualCardUseRecordByPage +
        "?sessionId=" +
        this.$common.getCookie("sessionId");
      let param1 = {
        beginDate: start + "T00:00:00.000Z",
        endDate: start + "T23:59:59.000Z",
        pageIndex: "1",
        pageSize: "1",
        storeId: localStorage.getItem("storeId")||''
        // userId: localStorage.getItem('userId')||''
      };
      this.$vux.loading.show({
        text: "正在获取当日的数据"
      });
      this.$common.post(url, param1, res => {
        setTimeout(() => {
          this.$vux.loading.hide();
        }, 800);
        if (res.status == 200) {
          this.sNum = res.data.count;
        } else {
          this.$vux.toast.show({
            text: res.msg,
            type: "warn",
            width: "auto"
          });
        }
      });
      let param2 = {
        beginDate: start + "T00:00:00.000Z",
        endDate: start + "T23:59:59.000Z",
        brandId: localStorage.getItem("storeBrandId")||'',
        pageIndex: "1",
        pageSize: "1"
        // userId: localStorage.getItem('userId')||''
      };
      this.$vux.loading.show({
        text: "正在获取当日的数据"
      });
      this.$common.post(url, param2, res => {
        this.$vux.loading.hide();
        if (res.status == 200) {
          this.bNum = res.data.count;
        } else {
          this.$vux.toast.show({
            text: res.msg,
            type: "warn",
            width: "auto"
          });
        }
      });
    }
  },
  components: {
    Tabbar,
    TabbarItem
  }
};
</script>

<style lang="less">
#orderData {
  .top {
    .one {
      margin-top: 63px;
      text-align: center;
      p {
        font-family: PingFang-SC-Bold;font-weight: 600;
        font-size: 16px;
        color: #333;
        margin-bottom: 23px;
      }
    }
    .two {
      margin-top: 138px;
      margin-left: 21.8%;
      > a {
        text-align: center;
        display: inline-block;
        width: 72.6%;
        height: 35px;
        line-height: 35px;
        border: 1px solid transparent;
        border-radius: 18px;
        background-color: #f02931;
        font-family:PingFang SC;
        font-weight:500;
        color:rgba(255,255,255,1);
        font-size: 14px;
        color: #fff;
        text-align: center;
        &:hover {
          background-color: #e1252c;
        }
        // &:last-child {
        //   border-color: #e1252c;
        //   color: #e1252c;
        //   background: transparent;
        //   margin-top: 13px;
        // }
      }
    }
  }

  .weui-tabbar {
    position: fixed;
    .weui-tabbar__item {
      img {
        width: 21px;
        height: 21px;
        margin-top: 3px;
      }
    }
    .weui-bar__item_on {
      img {
        width: 23px;
        height: 21px;
      }
      .weui-tabbar__label {
        span {
          font-family: PingFang-SC-Medium;
          font-size: 12px;
          color: #ec1b24;
        }
      }
    }
    &:before {
      border: none;
    }
  }
}
</style>
